import * as actionTypes from '../constants';

const initialState = {
  tesladata: [],
  // 记录tabbar点击高亮
  index: 2,
  // 记录详情页车选择的颜色
  colorIndex: 0,
  // 记录详情页轮子所选择的样式
  wheelIndex: 0
};

const reducer = (state = initialState, action) => {
  //根据type决定如何加工数据
  switch (action.type) {
    case actionTypes.CHANGE_TESLADATA:
      return {...state, tesladata: action.data}
    case actionTypes.CHANGE_INDEX:
      return {...state, index: action.data}
    case actionTypes.SET_COLORINDEX:
      return {...state, colorIndex: action.data}
    case actionTypes.SET_WHEELINDEX:
      return {...state, wheelIndex: action.data}
    default:
      return state;
  }
}

export default reducer;
